Убран вводящий в заблуждение статический метод Date::createFromText#91
Open
gromdron wants to merge 1 commit intobitrix-tools:mainfrom
Open
Убран вводящий в заблуждение статический метод Date::createFromText#91gromdron wants to merge 1 commit intobitrix-tools:mainfrom
gromdron wants to merge 1 commit intobitrix-tools:mainfrom
Conversation
Collaborator
|
Метод Проверьте, пожалуйста |
Contributor
Author
|
@neckita39 ваша правда - я поспешил назвать метод несуществующим. Описание сигнатуры метода (из класса namespace Bitrix\Main\Type;
class Date
/**
* Creates Date object from Text (return array of result object)
* Examples: "end of next week", "tomorrow morning", "friday 25.10"
*
* @param string $text
* @return DateTime|null
*/
public static function createFromText($text)
}Проверочный код: use Bitrix\Main\Type\Date;
var_dump(Date::createFromText("end of next week"));
var_dump(Date::createFromText("tomorrow morning"));
var_dump(Date::createFromText("friday 25.10"));Результат: NULL
NULL
NULLОднако для русскоязычной коробки use Bitrix\Main\Type\Date;
var_dump(Date::createFromText("вчера"));Выдал: object(Bitrix\Main\Type\DateTime)#263 (2) {
["value":protected]=>
object(DateTime)#261 (3) {
["date"]=>
string(26) "2026-02-26 19:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Moscow"
}
["userTimeEnabled":protected]=>
bool(true)
}Что очень странно, учитывая что по москве сейчас 15:50, а ссылается на 19:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Такого метода не существует в последней стабильной версии битрикса.
Кстати очень даже жаль, потому что часто приходится работать с разными системами и использовать разные форматы дат, поэтому в коде появляется такое: